<template>
	<view class="page-bg prize">
		<page-header title="抽奖详情"></page-header>
		<view class="container">
			<draw-details></draw-details>
			<draw-help v-if="false"></draw-help>
			<draw-participant></draw-participant>
			<view class="container-item mc-flex-center">
				<button type="primary" hover-class="none">参与更多</button>
			</view>
			<view class="margin-bottom36">
			  <banner-ad></banner-ad>
			</view>
		</view>
	</view>
</template>

<style lang="scss" scoped>
	.prize {
		color: #555555;
		font-size: 32rpx;
		
		.container {
			margin-top: 150rpx;
		}
		
		.container-item {
			position: relative;
			width: 690rpx;
			margin: 30rpx auto;
			z-index: 9;
			background-color: white;
			border-radius: 10rpx;
			padding: 10rpx;
						
			button{
				width: 650rpx;
				background-color: #e35a2e;
				border-radius: 1000px;
			}
		}
	}
</style>


<script>
	import drawDetails from '@/components/home/draw-details/index.vue'
	import drawParticipant from '@/components/home/draw-participant/index.vue'
	import drawHelp from '@/components/home/draw-help/index.vue'
	let gData = {};
	let _self;
	export default {
		components: {
			drawDetails,
			drawParticipant,
			drawHelp
		},
		data() {
			return {
				list: [],
				total: 0,
				status: "more",
				contentText: {
					contentdown: "点击加载",
					contentrefresh: "正在加载...",
					contentnomore: ""
				}
			}
		},
		onLoad(options) {
			_self = this;
			this.initList()
		},
		onUnload() {
			gData = {}; /*因为全局变量会保存，再次打开该页面时会造成一些数据错误 */
		},
		// 下拉刷新
		onPullDownRefresh() {
			this.initList();
		},
		// 上拉加载
		onReachBottom() {
			this.loadList();
		},
		methods: {
			// 初始化列表
			initList() {
				gData.page = 0;
				this.list = [];
				this.status = "more";
				this.loadList();
			},
			// 加载列表
			async loadList() {
				if (this.status == "more") {
					const page = gData.page + 1;
					this.status = "loading";
					const pageSize = 10;
					uni.showNavigationBarLoading();
					try {
						let data = await this.$api.home.myPrize({
							page: page, // 页数
							rows: pageSize //
						});
						console.log(data)
						
						
						const addList = data.list || [];
						this.list = this.list.concat(addList)
						gData.page = page;
						this.total = data.total;
						const noMore = (page * pageSize) >= data.total;
						this.status = noMore ? "noMore" : "more";
					} catch (e) {
						this.status = "more";
						console.log('request fail', e);
					}
				};
			},
			// ---------------------------------------
			// 保存二维码
			setFormId(e) {
				// _self.$api.setFormId(e);
			},
		},
	}
</script>